package com.keyancompany.zhongbaopingtai.activity;

import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.keyancompany.zhongbaopingtai.Constants;
import com.keyancompany.zhongbaopingtai.R;
import com.keyancompany.zhongbaopingtai.model.FriendModel;
import com.keyancompany.zhongbaopingtai.utils.IntentUtils;
import com.keyancompany.zhongbaopingtai.weight.CircleImageView;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.imageaware.ImageViewAware;

import butterknife.Bind;
import butterknife.BindString;
import butterknife.OnClick;

import static com.keyancompany.zhongbaopingtai.activity.ChatFriendActivity.BUNDLE_RES_INFO;

/**
 * 个人信息
 * Created by firefox on 2016/6/15.
 */
public class SelfPeopleInfoActivity extends BaseActivity {

    @BindString(R.string.friend_info_text)
    String title;
    @Bind(R.id.toolbar)
    Toolbar toolbar;
    @Bind(R.id.send_message)
    TextView sendMessage;
    @Bind(R.id.user_level)
    TextView userLevel;
    @Bind(R.id.introduction)
    TextView introduction;
    @Bind(R.id.name)
    TextView name;
    @Bind(R.id.address)
    TextView address;
    @Bind(R.id.labels)
    TextView labels;
    @Bind(R.id.user_head)
    CircleImageView userHead;

    FriendModel mFriendModel;

    @Override
    protected int getContentViewId() {
        return R.layout.activity_self_people_info;
    }

    @Override
    protected int getMenuId() {
        return 0;
    }

    @Override
    protected void initToolBar() {
        initToolBar(toolbar, title);
    }

    @OnClick(R.id.send_message)
    public void toChatView(View view) {
        Bundle bundle = new Bundle();
        bundle.putString("res", BUNDLE_RES_INFO);
        bundle.putString("userName", mFriendModel.getUsername());
        bundle.putString("pid", mFriendModel.getPID_());
        IntentUtils.startActivity(mContext, ChatFriendActivity.class, bundle);
    }

    @Override
    protected void setUpViews() {
        mFriendModel = (FriendModel) getIntent().getSerializableExtra(Constants.ITEM);

        ImageLoader.getInstance().displayImage(mFriendModel.getHeadpic(), userHead);

        if (!TextUtils.isEmpty(mFriendModel.getLevel())) {
            userLevel.setText(getString(R.string.user_level_text, "未知"));
        } else {
            userLevel.setText(getString(R.string.user_level_text, mFriendModel.getLevel()));
        }

        if (!TextUtils.isEmpty(mFriendModel.getResume())) {
            introduction.setText(mFriendModel.getResume());
        } else {
            introduction.setText("无");
        }

        name.setText(mFriendModel.getUsername());

        labels.setText(mFriendModel.getLabels());

        address.setText(mFriendModel.getAddress());
    }
}